{% load i18n pybb_tags %}

<div class="form-left">
  <h2>{% if forum %}{% trans "New Thread" %}{% else %}{% trans "New reply" %}{% endif %}</h2>
  <div class="user-info">
    <div class="avatar">
      <img src="{{ user|pybb_avatar_url }}" />
    </div>
    <div class="author-info">
      <p class="user-name">{{ user }}</p>
    </div>
    <div class="clear"></div>
  </div>
</div>

<div class="form-right">
  <form class="post-form" action="{% if forum %}{% url pybb_topic_add forum.pk %}{% else %}{% url pybb_post_add topic.pk %}{% endif %}" method="post" enctype="multipart/form-data">
    {% pybb_csrf %}
    <div class="preview-box" style="display: none">
        <div class="content"></div>
    </div>
    {{ form.as_p }}
    <div class="submit">
      <div class="post-new">
        <div class="post-new-left"></div>
        <input type="submit" value="{% trans 'Submit' %}" class="post-new-btn"/>
        <div class="post-new-right"></div>
      </div>
      <div class="post-new">
        <div class="post-new-left"></div>
        <input class="preview-button post-new-btn" type="button" value="{% trans 'Preview' %}" />
        <div class="post-new-right"></div>
      </div>
    </div>
  </form>
</div>
<div class="clear"></div>

<!--
<script type="text/javascript">
$(function() {
    $('.post-form .preview-button').click(function() {
        var raw_content = $.trim($('.post-form #id_body').val());

        args = {'content': raw_content}
        $.post('{% url pybb_post_ajax_preview %}', args, function(data) {
            if (data.error) {
                alert(data.error);
            } else {
                $('.preview-box .content').html(data.content);
                $('.preview-box').show();
            }
        }, 'json');
    });

    var i = 0;
    $('#id_attachment').change(function(){
        i++;
        var filename = $(this)[0].files[0].fileName;
        var filesize = $(this)[0].files[0].fileSize / 1024;
        filesize = Math.round(filesize);
        var link = '<a href="javascript://" onclick="$(this).parent().remove()">{% trans "Remove" %}</a>'
        $(this).clone(true).insertAfter(this).hide().attr({id:'id_attachment'+i, name:'attachment'+i}).wrap('<div></div>').parent().append(filename+'('+filesize+'Kb) '+link);
        $(this).val('');
    });
});

</script>
-->